package session

import "geeorm/log"

//调用s.db.Begin()得到*sql.Tx对象，赋值给s.tx
func (s *Session)Begin()(err error){
	log.Info("transaction begin")
	if s.tx,err=s.db.Begin();err!=nil{
		log.Error(err)
		return
	}
	return
}

func (s *Session)Commit()(err error){
	log.Info("transaction commit")
	if err=s.tx.Commit();err!=nil{
		log.Error(err)
	}
	return
}

func (s *Session)Rollback()(err error){
	log.Info("transaction rollback")
	if err=s.tx.Rollback();err!=nil{
		log.Error(err)
	}
	return
}


